home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1994 August: Tool Chest / Dev.CD Aug 94.toast / Sample Code / Snippets / Toolbox / EasyPlayRecord / EasyPlayRecord.c next >
Encoding:
C/C++ Source or Header  |  1992-07-15  |  1.2 KB  |  64 lines  |  [TEXT/MPS ]

  1. #include    <Quickdraw.h>
  2. #include    <Windows.h>
  3. #include    <dialogs.h>
  4. #include    <OSEvents.h>
  5. #include    <Memory.h>
  6. #include    <Packages.h>
  7. #include    <Sound.h>
  8. #include    <SoundInput.h>
  9. #include    <OSUtils.h>
  10.  
  11. #define    TRUE            0xFF
  12. #define    FALSE            0
  13.  
  14. main()
  15. {
  16.     Point                where = {20,20};
  17.     Point                whereto = {100,100};
  18.     OSErr                err;
  19.     SFReply                reply;
  20.     short                refnum;
  21.     char*                string;
  22.     Handle                SNDHand;
  23.     SndChannelPtr        chan;
  24.     
  25.     InitGraf(&qd.thePort);
  26.     FlushEvents(everyEvent, 0);
  27.     InitWindows();
  28.     InitDialogs(nil);
  29.     InitCursor();
  30.     
  31.     string = (char*) "\pPick a SND File";
  32.  
  33.     SFGetFile (where, (Str255) string, nil, -1, (SFTypeList) nil, nil, &reply);
  34.     err = FSOpen(reply.fName, reply.vRefNum, &refnum);
  35.     if (err != noErr)
  36.         Debugger();
  37.     
  38.     err = SndStartFilePlay (nil, refnum, 0, 74000, nil, nil, nil, TRUE);
  39.     if (err != noErr)
  40.         Debugger();
  41.         
  42.     SNDHand = NewHandle (0xc9000);
  43.     if (MemError() != noErr || SNDHand == nil)
  44.         Debugger();
  45.  
  46.     err = SndRecord (nil, whereto, siBestQuality, &SNDHand);
  47.     if (err != noErr)
  48.         Debugger();
  49.         
  50.     FSClose (refnum);
  51.  
  52.     chan = nil;
  53.     err = SndNewChannel (&chan, 0, 0, nil);
  54.     if (err != noErr)
  55.         Debugger();
  56.     
  57.     err = SndPlay (chan, SNDHand, FALSE);
  58.     if (err != noErr)
  59.         Debugger();
  60.  
  61.     err = SndDisposeChannel (chan,FALSE);
  62.     if (err != noErr)
  63.         Debugger();
  64. }